/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.menu;

import com.ivanbiz.generic.GenericDAOImpl;
import java.util.List;
import org.hibernate.Query;

/**
 *
 * @author User
 */
public class MenuDAOImpl extends GenericDAOImpl implements MenuDAO {

    public List getMenuByDepartement(long id) throws Exception {
        Query query = getSessionFactory().getCurrentSession().createQuery("from Menu b where b.departement.id=:id and b.flag='Y'");
        query.setParameter("id", id);
        return query.list();
    }

    public Menu getMenuByDeptAndUrl(long id, String url) throws Exception {
        Query query = getSessionFactory().getCurrentSession().createQuery("from Menu b where b.departement.id=:id and b.urlMenu=:url");
        query.setParameter("id", id);
        query.setParameter("url", url);
        return (Menu) query.uniqueResult();
    }
}
